package org.example.likou150.array;

/*
* https://leetcode.cn/problems/best-time-to-buy-and-sell-stock-ii/submissions/607837925/?envType=study-plan-v2&envId=top-interview-150
* */
public class MaxProfit2 {
    public int maxProfit(int[] prices) {
        int max=0;
        for(int i=0; i<prices.length-1; i++){
            if(prices[i] < prices[i+1]){
                max += prices[i+1] - prices[i];
            }
        }
        return max;
    }
}
